package com.chapter10;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

/**
 * 传递性
 */
public class Point {

    private final int x;

    private final int y;

    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
//        if (!(o instanceof Point))
//            return false;
//        Point point=(Point)o;
//        return point.x==x && point.y==y;
        if (o==null || o.getClass() != getClass())
            return false;
        Point point=(Point)o;
        return point.x==x && point.y==y;
    }

    public static void main(String[] args) {
        ColoPoint cp=new ColoPoint(1,2,"RED");
        Point p=new Point(1,2);
        ColorPoint1 cp1=new ColorPoint1(1,2,"RED");
        ColorPoint1 cp2=new ColorPoint1(1,2,"white");

        //System.out.println(p.equals(cp));
       // System.out.println(cp1.equals(cp2));

        CounterPoint counterPoint=new CounterPoint(1,2);
        Set<Point> set=new HashSet<>();
        set.add(new Point(1,2));
        System.out.println(set.contains(counterPoint));
    }
}
